package com.chenfan.mcn.model;

import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import java.io.Serializable;
import java.util.Date;

import com.chenfan.mcn.model.base.BaseEntity;
import lombok.Data;
import lombok.experimental.Accessors;
import org.apache.commons.lang3.ObjectUtils;

/**
 * <p>
 * 业务工作流关联表
 * </p>
 *
 * @author lizhejin
 * @since 2021-01-26
 */
@Data
@TableName("approval_flow")
@Accessors(chain = true)
public class ApprovalFlow implements Serializable {

    private static final long serialVersionUID = 1L;

    @TableId(value = "id", type = IdType.AUTO)
    private Long id;

    /**
     * 单据id
     */
    private Long srcId;

    /**
     * 流程id
     */
    private Long processId;

    /**
     * 审批id
     */
    private Long approvalId;

    /**
     * 执行状态,0已结束1进行中
     */
    private Boolean activeStatus;

    /**
     * 创建时间
     */
    private Date createDate;

    /**
     * 提起人
     */
    private Long userId;

    /**
     * 提起人姓名
     */
    private String userName;

    /**
     * 部门id
     */
    private Long departmentId;

    /**
     * 公司id
     */
    private Long companyId;

    /**
     * 租户id
     */
    private Long tenantId;


    /**
     * 添加提起人信息
     */
    public void addSubmitInfoIfNull(BaseEntity baseEntity) {
        this.userId = ObjectUtils.defaultIfNull(this.userId, baseEntity.getCreateBy());
        this.userName = ObjectUtils.defaultIfNull(this.userName, baseEntity.getCreateName());
        this.departmentId = ObjectUtils.defaultIfNull(this.getDepartmentId(), baseEntity.getDepartmentId());
        this.companyId = ObjectUtils.defaultIfNull(this.getCompanyId(), baseEntity.getCompanyId());
        this.tenantId = ObjectUtils.defaultIfNull(this.getTenantId(), baseEntity.getTenantId());
    }
}
